package com.kt.app.ui.components


import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties

@Composable
fun DialogSample() {
    var showDialog by remember { mutableStateOf(false) }
    Column {
        Button(onClick = {
            showDialog = true

        }) { Text("show dialog") }

        if(showDialog){
            Dialog(
                onDismissRequest = {
                    /*
                    dismiss dialog
                     */
                    showDialog = false
                },
                properties = DialogProperties(dismissOnBackPress = true, dismissOnClickOutside = true)
            ) {
                Card(modifier = Modifier.width(200.dp)) {
                    Text("Dialog content")
                }

            }
        }
        Button(onClick = {
        }) { Text("other sample") }

    }

}
@Composable
fun AlterDialogSample(){
    var showDialog by remember { mutableStateOf(false) }
    Button(onClick = {
        showDialog = true

    }) { Text("show dialog") }
    if(showDialog){
        AlertDialog(

            onDismissRequest = {
                showDialog = false
            },
            title = { Text("Dialog title") },
            text = { Text("Dialog content") },
            confirmButton = {
                Button(onClick = {
                    showDialog = false
                }) { Text("Confirm") }
            },
            dismissButton = {
                Button(onClick = {
                    showDialog = false
                }) { Text("Dismiss") }
            },
            shape = RoundedCornerShape(5.dp)
        )
    }


}

@Preview
@Composable
fun DialogSamplePreview() {
    AlterDialogSample()
}

